#include <stdio.h>
#include <string.h>

int main() {
    int N;
    scanf("%d", &N);
    
    int aa[17] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
   
    char b[11] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};

    int c = 1;
    
    for (int i = 0; i < N; i++) {
        char id[19];
        scanf("%s", id);  
        
        int sum = 0;
        
        for (int j = 0; j < 17; j++) {
            sum += (id[j] - '0') * aa[j];
        }
        
        int d = sum % 11;
        char e = b[d];
        
        if (e != id[17]) {
            printf("%s\n", id);
            c = 0;
        }
    }

    if (c) {
        printf("全部正确!\n");
    }

    return 0;
}
